{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>测评列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                <div  class="col-sm-2" style="width: 100px">
                    <div class="input-group" >  
                        <a href="{:url('questionAdd')}"><button class="btn btn-outline btn-primary" type="button">添加测评</button></a>
                    </div>
                </div>
                    <div  class="col-sm-2" style="width: 100px">
                        <div class="input-group" >
                            <a href="{:url('questionUp','type=1')}"><button class="btn btn-outline btn-primary" type="button">全部上架</button></a>
                        </div>
                    </div>

                    <div  class="col-sm-2" style="width: 100px">
                        <div class="input-group" >
                            <a href="{:url('questionUp','type=2')}"><button class="btn btn-outline btn-primary" type="button">全部下架</button></a>
                        </div>
                    </div>
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <div class="col-sm-2">

                                <input type="text" id="key" class="form-control" name="key" value="{$val}" placeholder="输入需查询的名称" />

                        </div>


                        <div class="col-sm-2">

                                <select class="form-control m-b chosen-select" name="cat_id" id='cat_id'>
                                    <option value="0">选择测评分类</option>
                                    {volist name="question_cat" id="vo"}
                                    <option value="{$vo.id}" {if condition="$cat_id eq $vo.id"}selected{/if}>{$vo.name}</option>
                                    {/volist}
                                </select>

                        </div>


                        <span class="input-group-btn">
                                 <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                         </span>
                    </form>

                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>
              <input type="hidden" value="{$page}" id="pp">
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover" id="tt">
                        <thead>
                            <tr class="long-tr">
                                <th>ID</th>
                                <th>所属类型</th>
                                <th>名称</th>
                                <th>大图</th>
<!--                                <th>测评费用</th>-->
<!--                                <th>已测</th>-->
                                <th>是否上架</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <script id="list-template" type="text/html">
                            {{# for(var i=0;i<d.length;i++){  }}

                            <tr class="long-td">
                                <td>{{d[i].id}}</td>
                                <td>{{d[i].c_name}}</td>
                                <td>{{d[i].name}}</td>
                                <td>
                                    <img src="{{d[i].cover}}" class="img-circle" style="width:35px;height:35px"/>
                                </td>
<!--                                <td>{{d[i].fee}}</td>-->
<!--                                <td>{{d[i].cp_num}}</td>-->
                                <td>
                                    {{# if(d[i].is_show==1){ }}
                                    <a class="red checkchildspan" href="javascript:;" onclick="gquestion_show_state({{d[i].id}});" status="{{d[i].id}}">
                                        <div id="zt1{{d[i].id}}"><span class="label label-info">上架</span></div>
                                    </a>
                                    {{# }else{ }}
                                    <a class="red checkchildspan" href="javascript:;" onclick="question_show_state({{d[i].id}});" status="{{d[i].id}}">
                                        <div id="zt1{{d[i].id}}"><span class="label label-danger">下架</span></div>
                                    </a>
                                    {{# } }}
                                </td>
                                <td>{{d[i].create_time}}</td>
                                <td>
                                    
                                    <a href="javascript:;" onclick="QuestionEdit({{d[i].id}})" class="btn btn-primary btn-outline btn-xs"><i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
									<a href="javascript:;" onclick="ShowQuestion({{d[i].id}})" class="btn btn-success btn-outline btn-xs"><i class="fa fa-tag"></i>题目管理</a>&nbsp;&nbsp;
									
									{{# if(d[i].ceping_type != 1){ }}
									<a href="javascript:;" onclick="ShowWeidu({{d[i].id}})" class="btn btn-success btn-outline btn-xs"><i class="fa fa-tag"></i>维度管理</a>&nbsp;&nbsp;
									{{# } }}
									
									{{# if(d[i].ceping_type==1){ }}
									<a href="javascript:;" onclick="ScoreEdit({{d[i].id}})" class="btn btn-success btn-outline btn-xs"><i class="fa fa-tag"></i>分数等级介绍</a>&nbsp;&nbsp;
									{{# }else{ }}
									<a href="javascript:;" onclick="ScoreEdit1({{d[i].id}})" class="btn btn-success btn-outline btn-xs"><i class="fa fa-tag"></i>等级介绍</a>&nbsp;&nbsp;
									{{# } }}
									<a href="javascript:;" onclick="QuestionDel({{d[i] .id}})" class="btn btn-danger btn-outline btn-xs"><i class="fa fa-trash-o"></i> 删除</a>
                                </td>
                            </tr>
                            {{# } }}
                        </script>
                        <tbody id="list-content"></tbody>
                    </table>
                    <div id="AjaxPage" style=" text-align: right;"></div>
                    <div id="allpage" style=" text-align: right;"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
   
    //laypage分页
    Ajaxpage();
    function Ajaxpage(curr){
        var key=$('#key').val();
        var cat_id=$('#cat_id').val();
        if(curr && curr >= 1){
            $('#pp').val(curr);
        }else{
            curr =  $('#pp').val();
        }
        $.getJSON('{:url("Ceping/index")}', {page: curr || 1,key:key,cat_id:cat_id}, function(data){
            $(".spiner-example").css('display','none'); //数据加载完关闭动画 
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var tpl = document.getElementById('list-template').innerHTML;
                laytpl(tpl).render(data, function(html){
                    document.getElementById('list-content').innerHTML = html;
                });
                laypage({
                    cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages:'{$allpage}',//总页数
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }

    //批量
    /*$("#tt").on('click','.checkall',function () {
        var check = $(this).prop("checked");
        $(".checkchild").prop("checked", check);
        var checks = document.getElementsByName("checkchild[]");
        console.log(checks,check);
        if(checks.length>0)
        {
            for(i=0;i<checks.length;i++){
                checks[i].checked = check;
                var a = $(".checkchildspan").eq(i);
                /!*if(a.attr('status') != -1)
                {
                    checks[i].checked = false;
                }*!/
            }
        }
    });*/




//编辑
function QuestionEdit(id){
    location.href = './questionEdit/id/'+id+'&page='+$('#pp').val();
}
function ScoreEdit(id){
    location.href = './ScoreEdit/id/'+id+'&page='+$('#pp').val();
}
function ScoreEdit1(id){
    location.href = './ScoreEdit1/id/'+id+'&page='+$('#pp').val();
}

    function QuestionEdit1(id){
        location.href = './questionEdit1/id/'+id+'&page='+$('#pp').val();
    }



//题目
function ShowQuestion(id){
    location.href = '/admin/ceping_question/index/cp_id/'+id+'.html';
}

//维度
function ShowWeidu(id){
    location.href = '/admin/ceping_weidu/index/cp_id/'+id+'.html';
}


//删除
function QuestionDel(id){
    lunhui.confirm(id,'{:url("questionDel")}');
}


//状态
function question_show_state(id){

    $.post('{:url("question_show_state")}',{id:id},function(data){
        if(data.code==1){
            var a='<span class="label label-danger">下架</span>'
            $('#zt1'+id).html(a);
            layer.msg(data.msg,{icon:2,time:1500,shade: 0.1,});
            return false;
        }else{
            var b='<span class="label label-info">上架</span>'
            $('#zt1'+id).html(b);
            layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
            return false;
        }
    });
    return false;

}




</script>
</body>
</html>